#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char const *argv[])
{
    //关闭标准输出
    close(STDOUT_FILENO);
    close(STDERR_FILENO);

    //打开一个文件用作标准输出
    int fd = open("test_log.txt", O_WRONLY | O_CREAT | O_APPEND,0644);
    if (fd == -1)
    {
        perror("Failed to open test_log.txt");
        return 1;
    }
    printf("This will be written to test_log.txt\n");
   
    return 0;
}
